#include "basesetting.h"
#include "ui_basesetting.h"
#include "databaseoperate.h"

baseSetting::baseSetting(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::baseSetting)
{
    ui->setupUi(this);
    initData();
    adeWidget = new addDeleteInfo;
    connect(adeWidget, SIGNAL(init()), this, SLOT(initInfo()));
    stWidget = new stepThroughWidget;
}

baseSetting::~baseSetting()
{
    delete ui;
}
void baseSetting::initInfo()
{
    ui->comboBox->clear();
    ui->comboBox_2->clear();
    ui->comboBox_3->clear();
    initData();
}
void baseSetting::initData()
{
    QMap<int, QString> sampleList;
    databaseOperate::Instance()->querySample(sampleList);
    QMapIterator<int, QString> i(sampleList);
    while(i.hasNext())
    {
        i.next();
        ui->comboBox_3->addItem(i.value(), i.key());
    }
    sampleList.clear();
    databaseOperate::Instance()->queryShifts(sampleList);
    QMapIterator<int, QString> j(sampleList);
    while(j.hasNext())
    {
        j.next();
        ui->comboBox->addItem(j.value(), j.key());
    }
    sampleList.clear();
    databaseOperate::Instance()->querySurveyor(sampleList);
    QMapIterator<int, QString> k(sampleList);
    while(k.hasNext())
    {
        k.next();
        ui->comboBox_2->addItem(k.value(), k.key());
    }
}

void baseSetting::on_comboBox_3_currentIndexChanged(int index)
{
    emit sampleComboxChanged(index);
}

void baseSetting::on_comboBox_currentTextChanged(const QString &arg1)
{
    emit sendShifts(arg1);
}

void baseSetting::on_comboBox_2_currentTextChanged(const QString &arg1)
{
    emit sendSuveyor(arg1);
}

void baseSetting::on_pushButton_6_clicked()
{
    adeWidget->show();
}

void baseSetting::on_pushButton_clicked()
{
    stWidget->show();
}
